/*********************************************************************************/
/*                                                                               */
/*      DMA Driver                                                               */
/*                                                                               */
/*      Last updated by:  CBS                                                    */
/*      Last update date: 12/12/25                                               */
/*      Revision:         0                                                      */
/*      Copyright:        DENSO                                                  */
/*                                                                               */
/*********************************************************************************/
#ifndef DMA_H
#define DMA_H

/*********************************************************************************/
/*  include files                                                                */
/*********************************************************************************/
#include "Std_Types.h"
#include "Dma_Cfg.h"
#include "MPC5674F_MVx264.h"

/*********************************************************************************/
/*  defines / data types / structs / unions / macros                             */
/*********************************************************************************/
typedef struct
{
    volatile U1 DMA_CHANNEL_PRIORITY;
    volatile U1 DMA_CHANNEL_PREEMTION_ENABLE;
}Dma_ChannelConfigType;

typedef enum
{
    DMA_TRANSFER_SIZE_8BITS,
    DMA_TRANSFER_SIZE_16BITS,
    DMA_TRANSFER_SIZE_32BITS,
    DMA_TRANSFER_SIZE_64BITS,
    DMA_TRANSFER_SIZE_16BYTES_BURST,
    DMA_TRANSFER_SIZE_32BYTES_BURST
}Dma_DataTranferSizeType;

typedef enum
{
    DMA_FIXED_PRIORITY_ARBITRATION = (U1)0,
    DMA_ROUND_ROBIN_ARBITRATION = (U1)1
}Dma_ChannelArbitrationType;

typedef struct
{
    const Dma_ChannelConfigType    *dmaChannelConfigPtr;
    Dma_ChannelArbitrationType     dmaChannelArbitration;
}Dma_ConfigType;

/********************************************************************************/
/*  API Functions                                                               */
/********************************************************************************/
void Dma_Init (const Dma_ConfigType *ConfigPtr);
void Dma_ConfigureChannel (struct tcd_t *tcd, Dma_ChannelType channel);
void Dma_ConfigureChannelTranferSize (U4 nbrOfIterations, Dma_ChannelType channel);
void Dma_ConfigureChannelSourceCorr (S4 sourceCorrection, Dma_ChannelType channel);
void Dma_ConfigureChannelDestinationCorr (S4 destinationCorrection, Dma_ChannelType channel);
void Dma_ConfigureDestinationAddress (U4 destAddr, Dma_ChannelType channel);
void Dma_ConfigureSourceAddress (U4 sourceAddr, Dma_ChannelType channel);
void Dma_StartChannel (Dma_ChannelType channel);
void Dma_StopChannel (Dma_ChannelType channel);
Std_ReturnType Dma_ChannelDone (Dma_ChannelType channel);
volatile struct tcd_t * Dma_GetTcd( Dma_ChannelType channel );

#endif  /* DMA_H */
/**** End Of File ****************************************************************/
